{% extends "base.html" %}
{% block title %}CDNTest homepage{% endblock %}

{% block head %}
  <link href="/static/style.css" rel="stylesheet" type="text/css" media="screen" />
  <script type="text/javascript" src="/static/main.js"></script>
  <script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
{% endblock %}

{% block content %}
    <table border="1" id="placements">
      <tbody>
        {% for framework, cdns in table.items %}
          <tr>
            {% if forloop.first %}
              <th><input type="checkbox" id="all-tests" checked="checked" /></th>
              {% for name, url in cdns %}
                <th>
                  <input type="checkbox" class="cdn" id="{{ name|slugify }}" />
                  <a href="{{ url }}" class="external">{{ name }}</a>
                </th>
              {% endfor %}
              </tr>
              <tr>
            {% endif %}

            <th>
              <input type="checkbox" class="framework" id="{{ framework.0|slugify }}" />
              <a href="{{ framework.1 }}" class="external">{{ framework.0 }}</a>
            </th>
            {% for cdn, placement in cdns.items %}
              <td>
                {% if placement %}
                  <input type="checkbox" class="placement cdn-{{ cdn.0|slugify }} framework-{{ framework.0|slugify }}" checked="checked" value="{{ placement }}" />
                {% endif %}
                <span></span>
              </td>
            {% endfor %}
          </tr>
        {% endfor %}
      </tbody>
    </table>
    <input type="button" name="start" value="Start selected tests" id="start-button" />
    <input type="button" name="stop" value="Stop tests" id="stop-button" />
    
    <form id="save-results" method="POST" action="/save/" style="display: none">
      <fieldset>
        <input type="hidden" name="scores" value="" id="scores" />
        <label>Your browser</label> <span id="browser-span"></span>
        <input name="browser" type="hidden" value="" id="browser" />
        <input name="version" type="hidden" value="" id="version" />
        <label>Your country</label> 
        <select name="country" id="country" >
          {% for country in countries %}
          <option value="{{ country.code2 }}">{{ country.name|safe }}</option>
          {% endfor %}
        </select>
      </fieldset>
      <input type="submit" value="Submit your score" />
    </form>
{% endblock %}
